package com.neusoft.restaurant.service.impl;

import com.neusoft.restaurant.common.exception.BizException;
import com.neusoft.restaurant.entity.ResAddress;
import com.neusoft.restaurant.entity.ResOrdersDetail;
import com.neusoft.restaurant.mapper.ResAddressMapper;
import com.neusoft.restaurant.mapper.ResOrdersDetailMapper;
import com.neusoft.restaurant.service.IResOrdersDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;

/**
 * 订单Service详情业务层处理
 * 
 * @author zhongda
 * @date 2023-12-10
 */
@Service
public class ResOrdersDetailServiceImpl implements IResOrdersDetailService
{
    @Autowired
    private ResOrdersDetailMapper resOrdersDetailMapper;
    @Autowired
    HttpServletRequest request;
//    @Autowired
//    private ResAddressMapper addressMapper;

    /**
     * 查询订单
     * 
     * @param id 订单主键
     * @return 订单
     */
    @Override
    public ResOrdersDetail selectResOrdersDetailById(Long id)
    {
        return resOrdersDetailMapper.selectResOrdersDetailById(id);
    }

    /**
     * 查询订单列表
     * 
     * @param resOrdersDetail 订单
     * @return 订单
     */
    @Override
    public List<ResOrdersDetail> selectResOrdersDetailList(ResOrdersDetail resOrdersDetail)
    {
        return resOrdersDetailMapper.selectResOrdersDetailList(resOrdersDetail);
    }

    /**
     * 新增订单详情
     * 
     * @param resOrdersDetail 订单
     * @return 结果
     */
    @Override
    public int insertResOrdersDetail(ResOrdersDetail resOrdersDetail)
    {

        //获得当前用户的id
        Long userId= (Long) request.getAttribute("userId");

        return resOrdersDetailMapper.insertResOrdersDetail(resOrdersDetail);
    }

    /**
     * 修改订单
     * 
     * @param resOrdersDetail 订单
     * @return 结果
     */
    @Override
    public int updateResOrdersDetail(ResOrdersDetail resOrdersDetail)
    {
        return resOrdersDetailMapper.updateResOrdersDetail(resOrdersDetail);
    }

    /**
     * 批量删除订单
     * 
     * @param ids 需要删除的订单主键
     * @return 结果
     */
    @Override
    public int deleteResOrdersDetailByIds(Long[] ids)
    {
        return resOrdersDetailMapper.deleteResOrdersDetailByIds(ids);
    }

    /**
     * 删除订单信息
     * 
     * @param id 订单主键
     * @return 结果
     */
    @Override
    public int deleteResOrdersDetailById(Long id)
    {
        return resOrdersDetailMapper.deleteResOrdersDetailById(id);
    }
}
